module.exports = function(success,error){

    const mongoose  = require('mongoose')

    const {DBNAME,DBHOST,DBPORT} = require('../config/config')

    mongoose.connect(`mongodb://${DBHOST}:${DBPORT}/${DBNAME}`)

    mongoose.connection.once('open',() => { 
        success()
    })

    mongoose.connection.on('error',() => { 
        error()
    })

    mongoose.connection.on('close',() => { 
        console.log('连接关闭！')
    })
}
